package com.example.mvplibrary.mvplibrary.ui.activity;

import com.example.mvplibrary.mvplibrary.model.BaseModel;
import com.example.mvplibrary.mvplibrary.presenter.BasePresenter;
import com.example.mvplibrary.mvplibrary.view.BaseView;

public abstract class BaseMvpActivity<V extends BaseView,M extends BaseModel,P extends BasePresenter<V,M>> extends BaseActivity{
    public P mPresenter;

    @Override
    protected void initData() {
        mPresenter=createPresenter();
        if(mPresenter!=null){
            mPresenter.bindView((V) this);
        }
        initEvent();
    }

    protected abstract void initEvent();

    protected abstract P createPresenter();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(mPresenter!=null){
            mPresenter.destroyView();
            mPresenter=null;
        }
    }
}
